import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import AutoImport from 'unplugin-auto-import/vite';
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
import path from "path";

console.log(path.resolve( '/src/asssets/icons/svg'))
// https://vitejs.dev/config/
console.log(path.resolve(process.cwd(), '/src/asssets/icons/svg'))
export default defineConfig({
    plugins: [
        vue(),
        vueJsx(),
        // 注册svg图标
        createSvgIconsPlugin({
            // 指定需要缓存的图标文件夹
            iconDirs: [path.resolve(process.cwd(), 'src/icons')],
            // 指定symbolId格式
            symbolId: 'icon-[dir]-[name]',
            /**
             * custom dom id
             * @default: __svg__icons__dom__
             */
            customDomId: 'e-svg',
        }),
        // 自动导入api
        AutoImport({
            imports: ['vue', 'vue-router', 'vuex'],
        }),
    ],
    esbuild: {loader: {'.js': '.jsx'}},
    css: {
        preprocessorOptions: {
            scss: {
                additionalData: `@import "@/scss/variables";`
            }
        }
    },
    resolve: {
        // 忽略后缀名的配置选项, 添加 .vue 选项时要记得原本默认忽略的选项也要手动写入
        extensions: ['.vue', '.js'],
        alias: {
            '@': path.resolve('./src'),
            '@utils': path.resolve('./src/utils')
        }
    }
})
